package cn.xiaomubiao.oschine.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import cn.xiaomubiao.oschine.R;
import cn.xiaomubiao.oschine.activity.MyInfoBaseActivity;
import cn.xiaomubiao.oschine.base.BaseNavFragment;
import cn.xiaomubiao.oschine.contants.Host;
import cn.xiaomubiao.oschine.fragment.myinfofragment.blog.MyInfoBlogFragment;
import cn.xiaomubiao.oschine.fragment.myinfofragment.collection.MyInfoCollectionFragment;
import cn.xiaomubiao.oschine.fragment.myinfofragment.focus.MyInfoFocusFragment;
import cn.xiaomubiao.oschine.fragment.myinfofragment.message.MyInfoMessageFragment;
import cn.xiaomubiao.oschine.util.UIUtils;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * @author
 * @version 1.0
 * @date 2017/4/2
 * 
 * MyInformationFragment ---- 
 * 
 * 
 * 
 */

public class MyInformationFragment extends BaseNavFragment {

  
    @BindView(R.id.myinfo_num)
    RelativeLayout mMyinfoNum;
    @BindView(R.id.myinfo_collection)
    RelativeLayout mMyinfoCollection;
    @BindView(R.id.myinfo_focus)
    RelativeLayout mMyinfoFocus;
    @BindView(R.id.myinfo_fans)
    RelativeLayout mMyinfoFans;
    Unbinder unbinder;
    @BindView(R.id.myinfo_zxing)
    ImageView mMyinfoZxing;
    @BindView(R.id.info_num_3)
    TextView mInfoNum3;
    @BindView(R.id.my_info_message)
    TextView mMyInfoMessage;
    @BindView(R.id.my_info_blog)
    TextView mMyInfoBlog;
    @BindView(R.id.my_info_note)
    TextView mMyInfoNote;
    @BindView(R.id.my_info_team)
    TextView mMyInfoTeam;
    private View mView;
    private Intent mIntent2;

    @Override
    public View initView() {
        mView = View.inflate(getActivity(), R.layout.view_myinformation_fragment, null);
        CircleImageView imageView = (CircleImageView) mView.findViewById(R.id.ico_portrait);
        Glide.with(UIUtils.getContext()).load(Host.HOST_DEFAULT+"images/uploads/user/496/993896_100.jpg?t=1431856188000").into(imageView);
        return mView;
    }

    @Override
    public void initData() {

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.myinfo_num, R.id.myinfo_collection, R.id.myinfo_focus, R.id.myinfo_fans,R.id.my_info_message, R.id.my_info_blog, R.id.my_info_note, R.id.my_info_team})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.myinfo_num:
                break;
            case R.id.myinfo_collection:

                Intent intent1 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
                intent1.putExtra("className" , MyInfoCollectionFragment.class.getName());
                intent1.putExtra("title","用户收藏");
                startActivity(intent1);
                break;
            case R.id.myinfo_focus:
                mIntent2 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
                mIntent2.putExtra("className" , MyInfoFocusFragment.class.getName());
                mIntent2.putExtra("title","关注");
                mIntent2.putExtra("id","关注");
                startActivity(mIntent2);
                break;
            case R.id.myinfo_fans:
                mIntent2 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
                mIntent2.putExtra("className" , MyInfoFocusFragment.class.getName());
                mIntent2.putExtra("tag","粉丝");
                mIntent2.putExtra("title","粉丝");
                startActivity(mIntent2);
                break;
            case R.id.myinfo_zxing:


             /*
               这是不带logo的二维码，需要一个imageView，不知道东辉想布局哪里，所以就复制在这里啦
              String textContent = "暂且为模拟数据，等待有数据时这里更改";
                if (TextUtils.isEmpty(textContent)) {
                    Toast.makeText(getActivity(), "您的输入为空!", Toast.LENGTH_SHORT).show();
                    return;
                }
                Bitmap mBitmap;
                ImageView imageView = new ImageView(getContext());
                mBitmap = CodeUtils.createImage(textContent, 400, 400, null);
                imageView.setImageBitmap(mBitmap);
                */
                
                break;
            case R.id.my_info_message:
                Intent intent3 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
                intent3.putExtra("className" , MyInfoMessageFragment.class.getName());
                intent3.putExtra("title","消息");
                startActivity(intent3);
                break;
            case R.id.my_info_blog:
                Intent intent4 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
                intent4.putExtra("className" , MyInfoBlogFragment.class.getName());
                intent4.putExtra("title","博客");
                startActivity(intent4);
                break;
            case R.id.my_info_note:
                Intent intent5 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
//                intent5.putExtra("className" , MyInfoCollectionFragment.class.getName());
                intent5.putExtra("title","便签");
                startActivity(intent5);
                break;
            case R.id.my_info_team:
                Intent intent6 = new Intent(UIUtils.getContext(), MyInfoBaseActivity.class);
//                intent6.putExtra("className" , MyInfoCollectionFragment.class.getName());
                intent6.putExtra("title","团队");
                startActivity(intent6);
                break;
        }
    }

 
}
